package com.zzq.controller;

import com.zzq.pojo.Result;
import com.zzq.pojo.TenderInfo;
import com.zzq.service.TendererInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/tendererInfo")
public class TendererInfoController {

    @Autowired
    private TendererInfoService tendererInfoService;

    @GetMapping("/allTendererInfo")
    public Result<List<TenderInfo>> allTendererInfo() {
        List<TenderInfo> ti=tendererInfoService.list();
        return Result.success(ti);
    }

    @GetMapping("/someTendererInfo")
    public Result<List<TenderInfo>> someTendererInfo() {
        List<TenderInfo> ti=tendererInfoService.some();
        return Result.success(ti);
    }

    @PutMapping("/check")
    public Result check(int no){
        tendererInfoService.check(no);
        return Result.success();
    }

    @PutMapping("/elect")
    public Result elect(int no){
        tendererInfoService.elect(no);
        return Result.success();
    }

    @GetMapping("/select")
    public Result<List<TenderInfo>> select(@RequestParam(required = false) String manufacturer,@RequestParam(required = false) String state){
        List<TenderInfo> ti=tendererInfoService.select(manufacturer,state);
        return Result.success(ti);
    }

    @GetMapping("/selectByName")
    public Result<List<TenderInfo>> selectByName(String name){
        List<TenderInfo> ti=tendererInfoService.selectByName(name);
        return Result.success(ti);
    }

    @PostMapping("/add")
    public Result add(@RequestBody TenderInfo tenderInfo){
        tendererInfoService.add(tenderInfo);
        return Result.success();
    }

    @PutMapping("update")
    public Result update(@RequestBody TenderInfo tenderInfo){
        tendererInfoService.update(tenderInfo);
        return Result.success();
    }
}
